<template>
  <div class="layout">
    <div class="search-default" v-if="!res.list[0].backgroundImage">
      <div class="search">
        <Icon type="ios-search" />{{ res.list[0].title }}
      </div>
    </div>
    <div class="search-area" v-else :style="searchStyle">
      <div class="search-in-img">
        <Icon type="ios-search" />{{ res.list[0].title }}
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ["res"],
  computed: {
    searchStyle() {
      let style = {};
      let curItem = this.res?.list[0];
      if (curItem && curItem.backgroundImage) {
        // style['border'] = '1px solid red'
        style["background-image"] = `url(${curItem.backgroundImage})`;
        // style['padding'] = '0 3vw'
        style["background-size"] = "100% 100%";
        style["background-repeat"] = "no-repeat";
      }
      return style;
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./tpl.scss";
.search-default {
  padding: 8px;
  background: #ffffff;
}
.search {
  height: 32px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ededed;
}
.layout {
  padding: 0;
  background: rgba(0, 0, 0, 0);
}
.search-area{
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ededed;
}
.search-in-img{
  width: 90%;
  border-radius: 24px;
  background: #fff;
  padding: 5px 3px;
}
</style>
